import { FBXLoader } from "three/examples/jsm/loaders/FBXLoader";
import * as THREE from "three";
export default function group(){
    var loader = new FBXLoader(); //创建一个FBX加载器
      loader.load("/sanjiaomian/DXD-sanjiaomian.fbx", function (obj) {
        console.log(obj, "大雄殿模型我加载了"); //查看加载后返回的模型对象
        obj.scale.set(0.01, 0.01, 0.01);
        obj.traverse((child) => {
          console.log(child, "child");
        //   if(child.name=='FGS_QJ1_FGS_DXD_QJ_FGS_DXD_TS2'){

        //   }
          if (child.isMesh || child.isGroup) {
            child.frustumCulled = false;
            // child.position.set(0, -10, -20);
          }
        });
        window.threeScene.add(obj);
      });
      let domContainer = document.getElementById("threeContainer");
      domContainer?.addEventListener("mousemove", onMousemove);
}
/**鼠标移动捕获点坐标 */
function onMousemove(event: any) {
    console.log(event,'onMousemove我触发了');
    const pointer = new THREE.Vector2();
    pointer.x = (event.offsetX / window.innerWidth) * 2 - 1;
    pointer.y = -(event.offsetY / window.innerHeight) * 2 + 1;
    const raycaster = new THREE.Raycaster();
    raycaster.setFromCamera(pointer, window.camera);
    const intersects = raycaster.intersectObjects(window.threeScene.children, true);
    // drawLine(pointArrVector3[1], pointArrVector3[2]);
    if (intersects.length > 0) {
        intersects[0].object.material.color.set(0xff0000);
        console.log(intersects,'intersects');
        // const vposition = intersects[0].point;
    }
}